home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / sleipnir165.exe / {app} / developers / ExPanel / Generic / TabList.c < prev   
C/C++ Source or Header  |  2004-06-27  |  8KB  |  334 lines

  1. /*-----------------------------------------------------------------------------
  2.  * Sleipnir Sample Extended Panel Plugin
  3.  * Copyright (C) 2004 by Yasuyuki Kashiwagi. All Rights Reserved.
  4.  *
  5.  * Version 1.1
  6.  *
  7.  * âTâôâvâïègÆúâpâlâïâvâëâOâCâôé┼é╖üB
  8.  *
  9.  * é▒é╠â\ü[âXé╠ëⁿò╧üEözòzé═Ä⌐ùRé╔ìsé┴é─é¡é╛é│éóüB
  10. -----------------------------------------------------------------------------*/
  11.  
  12.  
  13. #include <windows.h>
  14. #include "../SPlugin.h"
  15.  
  16.  
  17. #ifdef __cplusplus
  18. #define DLLExport extern "C" __declspec (dllexport)
  19. #else
  20. #define DLLExport __declspec (dllexport)
  21. #endif
  22.  
  23.  
  24.  
  25. /*---------------------------------------------------------------------------*/
  26. /* âOâìü[âoâïò╧Éö                                                            */
  27. /*---------------------------------------------------------------------------*/
  28.  
  29. HINSTANCE    g_hInstance    = NULL;
  30. HWND        g_hWnd        = NULL;
  31. HWND        g_hChildWnd    = NULL;
  32.  
  33.  
  34.  
  35. /*---------------------------------------------------------------------------*/
  36. /* âGâôâgâèü[â|âCâôâg                                                        */
  37. /*---------------------------------------------------------------------------*/
  38.  
  39. BOOL WINAPI DllMain
  40. (
  41.     HINSTANCE hinstDLL, 
  42.     DWORD fdwReason, 
  43.     LPVOID lpvReserved
  44. )
  45. {
  46.     if (fdwReason == DLL_PROCESS_ATTACH) 
  47.     {
  48.         g_hInstance = hinstDLL;
  49.     }
  50.     
  51.     return TRUE;
  52. }
  53.  
  54.  
  55.  
  56. /*---------------------------------------------------------------------------*/
  57. /* âvâëâOâCâôÅεò±Äµô╛                                                        */
  58. /*---------------------------------------------------------------------------*/
  59.  
  60. DLLExport SPX_USHORT SPX_CALL SPX_GetPluginInfo()
  61. {
  62.     return MAKEWORD(SPX_PLUGIN_EXTENDED_PANEL, SPX_EXTENDED_PANEL_VERSION);
  63. }
  64.  
  65.  
  66.  
  67. /*---------------------------------------------------------------------------*/
  68. /* WM_SIZE                                                                   */
  69. /*---------------------------------------------------------------------------*/
  70.  
  71. static void OnSize
  72. (
  73.     int cx, 
  74.     int cy
  75. )
  76. {
  77.     if (IsWindow(g_hChildWnd))
  78.     {
  79.         MoveWindow(g_hChildWnd, 0, 0, cx, cy, TRUE);
  80.     }
  81. }
  82.  
  83.  
  84.  
  85. /*---------------------------------------------------------------------------*/
  86. /* WM_COMMAND                                                                */
  87. /*---------------------------------------------------------------------------*/
  88.  
  89. static void OnCommand
  90. (
  91.     HWND hWndCtrl, 
  92.     WORD wNotify, 
  93.     WORD wId
  94. )
  95. {
  96.     if (wNotify == LBN_DBLCLK)
  97.     {
  98.         MessageBox
  99.             (
  100.                 g_hWnd, 
  101.                 "The item was selected.", 
  102.                 "Notify", 
  103.                 MB_OK|MB_ICONINFORMATION
  104.             );
  105.     }
  106. }
  107.  
  108.  
  109.  
  110. /*---------------------------------------------------------------------------*/
  111. /* ÉeâEâBâôâhâEâRü[âïâoâbâNè╓Éö                                              */
  112. /*---------------------------------------------------------------------------*/
  113.  
  114. static LRESULT CALLBACK WndCallbackProc
  115. (
  116.     HWND    hWnd,
  117.     UINT    unMsg,
  118.     WPARAM    wParam,
  119.     LPARAM    lParam
  120. )
  121. {
  122.     /* âèâXâgâ{âbâNâXé╠Æ╩ÆmâüâbâZü[âWé≡é▒é▒é┼Åêù¥é╡é─é¡é╛é│éó */
  123.     
  124.     switch (unMsg) {
  125.     case WM_SIZE:
  126.         OnSize(lParam & 0xFFFF, (lParam >> 16) & 0xFFFF);
  127.         break;
  128.         
  129.     case WM_COMMAND:
  130.         OnCommand((HWND)lParam, (wParam >> 16) & 0xFFFF, wParam & 0xFFFF);
  131.         break;
  132.     }
  133.     
  134.     return DefWindowProc(hWnd, unMsg, wParam, lParam);
  135. }
  136.  
  137.  
  138.  
  139. /*---------------------------------------------------------------------------*/
  140. /* SPX_Create                                                                */
  141. /*---------------------------------------------------------------------------*/
  142.  
  143. static SPX_HWND SPX_CALL SPX_CreateProc
  144. (
  145.     SPX_ISleipnir* ipSleipnir, 
  146.     SPX_HWND hWndParent
  147. )
  148. {
  149.     WNDCLASS    tThisClass;
  150.     const char    szClassName[] = "Extended Panel Plugin Sample";
  151.  
  152.     tThisClass.style            = CS_HREDRAW | CS_VREDRAW;
  153.     tThisClass.lpfnWndProc        = WndCallbackProc;
  154.     tThisClass.cbClsExtra        = 0;
  155.     tThisClass.cbWndExtra        = 0;
  156.     tThisClass.hInstance        = g_hInstance;
  157.     tThisClass.hIcon            = NULL;
  158.     tThisClass.hCursor            = LoadCursor(NULL, IDC_ARROW);
  159.     tThisClass.hbrBackground    = GetStockObject(WHITE_BRUSH);
  160.     tThisClass.lpszMenuName        = NULL;
  161.     tThisClass.lpszClassName    = szClassName;
  162.  
  163.     RegisterClass(&tThisClass);
  164.  
  165. //    if (!RegisterClass(&tThisClass))
  166. //        return NULL;
  167.  
  168.     /* ÉeâEâBâôâhâEé≡ì∞ɼé╖éΘ */
  169.     g_hWnd = CreateWindow
  170.         (
  171.             szClassName,
  172.             "",
  173.             WS_CHILD|WS_VISIBLE,
  174.             0,
  175.             0,
  176.             200,
  177.             200,
  178.             hWndParent,
  179.             NULL,
  180.             g_hInstance,
  181.             NULL
  182.         );
  183.  
  184.      if (g_hWnd == NULL)
  185.          return NULL;
  186.  
  187.     /* ÄqâEâBâôâhâEé≡ì∞ɼé╖éΘ */
  188.     g_hChildWnd = CreateWindow
  189.         (
  190.             "LISTBOX",
  191.             "",
  192.             WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_NOTIFY|LBS_NOINTEGRALHEIGHT,
  193.             0,
  194.             0,
  195.             200,
  196.             200,
  197.             g_hWnd,
  198.             NULL,
  199.             g_hInstance,
  200.             0
  201.         );
  202.  
  203.     if (g_hChildWnd == NULL)
  204.     {
  205.         DestroyWindow(g_hWnd);
  206.         return NULL;
  207.     }
  208.  
  209.     /* âtâHâôâgé≡èäéΦôûé─éΘ */
  210.     SendMessage
  211.         (
  212.             g_hChildWnd,
  213.             WM_SETFONT,
  214.             (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 
  215.             (LPARAM)FALSE
  216.         );
  217.  
  218.     /* ÉeâEâBâôâhâEé≡ò╘é╖ */
  219.     return g_hWnd;
  220. }
  221.  
  222.  
  223.  
  224. /*---------------------------------------------------------------------------*/
  225. /* SPX_Destroy                                                               */
  226. /*---------------------------------------------------------------------------*/
  227.  
  228. static SPX_LONG SPX_CALL SPX_DestroyProc
  229. (
  230.     SPX_ISleipnir* ipSleipnir, 
  231.     SPX_HWND hWnd
  232. )
  233. {
  234.     DestroyWindow(g_hChildWnd);
  235.     DestroyWindow(g_hWnd);
  236.  
  237.     return SPX_ERR_CODE_SUCCESS;
  238. }
  239.  
  240.  
  241.  
  242. /*---------------------------------------------------------------------------*/
  243. /* SPX_Idle                                                                  */
  244. /*---------------------------------------------------------------------------*/
  245.  
  246. static SPX_LONG SPX_CALL SPX_IdleProc
  247. (
  248.     SPX_ISleipnir* ipSleipnir, 
  249.     SPX_HWND hWnd
  250. )
  251. {
  252.     if (IsWindow(g_hChildWnd))
  253.     {
  254.         int i;
  255.         SPX_ULONG qCount;
  256.         SPX_CHAR* caTitle;
  257.  
  258.         SendMessage(g_hChildWnd, LB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
  259.         
  260.         if (ipSleipnir->SendMessage(SPX_SM_GETPAGECOUNT, (SPX_ULONG)&qCount, 0) == SPX_ERR_CODE_SUCCESS)
  261.         {
  262.             for (i=0; i<qCount; i++)
  263.             {
  264.                 if (ipSleipnir->SendMessage(SPX_SM_GETTITLE, (SPX_ULONG)i, (SPX_ULONG)&caTitle) == SPX_ERR_CODE_SUCCESS)
  265.                 {
  266.                     SendMessage(g_hChildWnd, LB_ADDSTRING, (WPARAM)0, (LPARAM)caTitle);
  267.                     ipSleipnir->Free(caTitle);
  268.                 }
  269.             }
  270.         }
  271.     }
  272.  
  273.     return SPX_ERR_CODE_SUCCESS;
  274. }
  275.  
  276.  
  277.  
  278. /*---------------------------------------------------------------------------*/
  279. /* SPX_Property                                                              */
  280. /*---------------------------------------------------------------------------*/
  281.  
  282.  
  283. static SPX_LONG SPX_CALL SPX_PropertyProc
  284. (
  285.     SPX_ISleipnir* ipSleipnir, 
  286.     SPX_HWND hWnd,
  287.     SPX_ULONG x,
  288.     SPX_ULONG y
  289. )
  290. {
  291.     MessageBox
  292.     (
  293.         hWnd, 
  294.         "TabList\n\n"
  295.             "Copyright (C) 2004 by Yasuyuki Kashiwagi\n"
  296.             "All Rights Reserved.", 
  297.         "TabList Plugin", 
  298.         MB_OK|MB_ICONINFORMATION
  299.     );
  300.  
  301.     return SPX_ERR_CODE_SUCCESS;
  302. }
  303.  
  304.  
  305.  
  306. /*---------------------------------------------------------------------------*/
  307. /* âvâëâOâCâôÅëè·ë╗                                                          */
  308. /*---------------------------------------------------------------------------*/
  309.  
  310. DLLExport SPX_LONG SPX_CALL SPX_Initialize
  311. (
  312.     SPX_IBrowserEventListener* ipEvent
  313. )
  314. {
  315.     ipEvent->OnCreate    = SPX_CreateProc;
  316.     ipEvent->OnDestroy    = SPX_DestroyProc;
  317.     ipEvent->OnIdle        = SPX_IdleProc;
  318.     ipEvent->OnProperty    = SPX_PropertyProc;
  319.     
  320.     return SPX_ERR_CODE_SUCCESS;
  321. }
  322.  
  323.  
  324.  
  325. /*---------------------------------------------------------------------------*/
  326. /* Visual C++ ùp âGâNâXâ|ü[âgû╝é╠ò╧è╖                                        */
  327. /*---------------------------------------------------------------------------*/
  328.  
  329. #ifdef _MSC_VER
  330. #pragma comment(linker, "/EXPORT:SPX_GetPluginInfo=_SPX_GetPluginInfo@0")
  331. #pragma comment(linker, "/EXPORT:SPX_Initialize=_SPX_Initialize@4")
  332. #endif
  333.  
  334.